#ifndef _KB_RGB_INT_TYPE_H_
#define _KB_RGB_INT_TYPE_H_

#include <stdint.h>
#include "SimplexNoises_Int.h"
//#include "kbRGB/kbRGB.h"

#ifdef __cplusplus
extern "C" {
#endif

#if 1
#define KB_ROWS KBRGB_ANGLE_SIZE
#else
#define KB_ROWS 6
#endif
#define KB_COLS KBRGB_ANGLE_SIZE

/*************************************************************************************************\
|        cledMatrixView                                                                            |
\*************************************************************************************************/
struct mled_view_t{
	uint8_t keys[KB_ROWS][KB_COLS];
	uint8_t rgb[KB_ROWS][KB_COLS];
};
struct mled_view_diffusion_t{
	uint8_t keys[KB_ROWS][KB_COLS];
//	int16_t move_cnt;       // 移动计数器,控制移动效果
	int16_t color_cnt;
	union {
		uint16_t pix;
		struct { int8_t x; int8_t y; };
	}pixel[7];//, kb;
	uint16_t radii[7];
	uint8_t cnt[7];
};


/*************************************************************************************************\
|        Advanced [13]                                                                            |
\*************************************************************************************************/
struct kbRGB_Int_BouncingBall{
    int32_t x,y;
};
struct kbRGB_Int_BouncingBall_t{
    int radius;
    int gravity;
    int dropHeightPercent;
    int spectrumVelocity;
    int horizontalVelocity;
    struct kbRGB_Int_BouncingBall Ball;
};
struct kbRGB_Int_FractalMotion_t{
    uint32_t random_color;
    uint32_t next_random_color;
    unsigned int val_mult;// = 100;
    float inv_val_mult;// = 0.01f;//1.f / val_mult;
    float random_tick;// = 0.f;
    unsigned int thickness;// = 1;
    float amplitude;// = 6.f;
    float frequency;// = 30.f;
    float freq_m1;// = 2.1;
    float freq_m2;// = 4.5;
    float freq_m3;// = 1.72;
    float freq_m4;// = 1.121;
    float freq_m5;// = 4.0;
    float freq_m6;// = 2.221;
    float freq_m7;// = 0.437;
    float freq_m8;// = 5.0;
    float freq_m9;// = 2.1122;
    float freq_m10;// = 1.5;
    float freq_m11;// = 1.72;
    float freq_m12;// = 0.06;
};
#define KBRGB_RAIN_SIZE   (10)
#define  KB_RGB_BUBBLES    6

struct kbRGB_Int_Bubbles_t {
    uint16_t    speeds[KB_RGB_BUBBLES];
    uint32_t    bubbles[KB_RGB_BUBBLES];
    uint16_t  bubblesSize;//=0;
    uint32_t  colors[KB_RGB_BUBBLES];
    unsigned int max_bubbles;// = KB_RGB_BUBBLES;
    unsigned int rarity;// = 8;
    unsigned int speed_mult;// = 10;
    unsigned int max_expansion;// = 100;
    unsigned int thickness;// = 10;
    struct {
            int16_t x, y;
    } centers[KB_RGB_BUBBLES];
};
struct kbRGB_Int_MovingPanes_t {
    uint16_t hsv_hue1;
    uint16_t hsv_hue2;
};

struct kbRGB_Int_Drop {
    int32_t progress;
    uint32_t color;
    unsigned int col;
    int32_t speed_mult;
    //uint32_t progress;
    //uint16_t speed_mult;
};
struct kbRGB_Int_Rain_t {
    struct kbRGB_Int_Drop drops[KBRGB_RAIN_SIZE];
    uint16_t dropsSize;//=0;
};
struct kbRGB_Int_SmoothBlink_t{
    uint32_t current_color_1;
    uint32_t current_color_2;
    uint32_t random_color_1;
    uint32_t random_color_2;
    uint32_t next_color_1;
    uint32_t next_color_2;
    //float pulses_total_duration;
    //float total_effect_duration;
    float value;// = 1.0;
    double random_fade_timer;// = 0;
    //float interval;// = 2.0;
    float strength;// = 0.5;
    //unsigned int pulses;// = 2;
    float pulse_duration;// = 0.5;
    int rendering;// = Circle;
};
struct kbRGB_Int_NewStar {
    //unsigned int      Index;
    uint32_t            Color;
    uint16_t            LED;
    // 注: state的计算包含大量浮点运算,这里转换为整形计算,精度为 1/64
    //float             state;
    int16_t             state; // *64 2^6
};
struct kbRGB_Int_StarryNight_t{ // 星空
    struct kbRGB_Int_NewStar CurrentStars[20];
    uint16_t CurrentStarsSize;//=0;
};
struct kbRGB_Int_Wavy_t{
    int        Dir;// = 1 ;
    int32_t      SineProgress;//      = 10.0f;
    int32_t      WaveProgress;//      = 60.0f;
    int32_t      WaveFrequency;//     = 2;
    int32_t      WaveSpeed;//         = 30;
    int32_t      OscillationSpeed;//  = 50;
    uint32_t   RandomColors[2];
};
/*************************************************************************************************\
|        Beams [2]                                                                                |
\*************************************************************************************************/
struct kbRGB_Int_Beams_t{
    hsv_t hsv1;
    hsv_t hsv2;
//    double sine_x;// = 0;
//    double sine_y;// = 0;
    int v_speed;// = 10;
    int h_speed;// = 15;
    int glow;// = 30;
    int thickness;// = 1;
    int RotatingMode;
};
#ifndef _KB_RGB_H_
struct kbRGB_Beams_t{
    hsv_t hsv1;
    hsv_t hsv2;
    uint16_t hsv_hue1;
    uint16_t hsv_hue2;
//    double sine_x;// = 0;
//    double sine_y;// = 0;
    int v_speed;// = 10;
    int h_speed;// = 15;
    int glow;// = 30;
    int thickness;// = 1;
    int RotatingMode;
};
#endif
struct kbRGB_Int_NoiseMap_t{
    int octaves;// = 2;
    int motion;// = 0;
    int motion_speed;// = 1;
    struct SimplexNoise_Int_t Noise;
};
/*************************************************************************************************\
|        Random [2]                                                                               |
\*************************************************************************************************/
struct kbRGB_Int_Flower {
    uint32_t hue:22;
    uint32_t speed_mult:10;// = 1.f;
};
#ifndef _KB_RGB_H_
struct kbRGB_Flower {
    uint32_t hue:22;
    uint32_t speed_mult:10;// = 1.f;
};
struct kbRGB_Int_Lightning_t {
    hsv_t hsv;
    uint16_t id;
};
#endif
struct kbRGB_Lightning_t {
    hsv_t hsv;
    uint16_t id;
};
#define LightningsSizeMax   32

struct kbRGB_Int_RainbowHypn_t{
    uint32_t animation_speed;// = 10.f;
    uint32_t color_rotation_speed;// = 50.f;
    unsigned int animation_direction;// = 0;
    unsigned int color_rotation_direction;// = 0;
    unsigned int spacing;// = 1;
    unsigned int thickness;// = 1;
};

/*************************************************************************************************\
|        Simple [11]                                                                              |
\*************************************************************************************************/
/*************************************************************************************************\
|        Mosaic [9]                                                                               |
\*************************************************************************************************/
struct kbRGB_Int_Mosaic_t {
    //hsv_t hsv;
    //float brightness;// = 0.f;
    uint16_t brightness;// = 0.f;
    //float decrease_speed_mult;// = 1.f;
    uint16_t decrease_speed_mult;// = 1.f;
};
#ifndef _KB_RGB_H_
struct kbRGB_Mosaic_t {
    //hsv_t hsv;
    //float brightness;// = 0.f;
    uint16_t brightness;// = 0.f;
    //float decrease_speed_mult;// = 1.f;
    uint16_t decrease_speed_mult;// = 1.f;
};
#endif
/*************************************************************************************************\
|        MotionPoints [9]                                                                              |
\*************************************************************************************************/
#ifndef _KB_RGB_H_
enum kbRGB_Dir {
    LEFT = 0,
    RIGHT = 1,
    UP = 2,
    DOWN = 3
};
#endif
struct kbRGB_Int_MovingPoint
{
    int32_t x;// = 0.f;
    int32_t y;// = 0.f;

    uint32_t speed_mult;// = 1.f;

    enum kbRGB_Dir dir;

    uint32_t color;
};
#define kbRGB_pointsSize    8

struct kbRGB_Int_Swap_t{
    uint32_t random1;
    uint32_t random2;
};
struct kbRGB_Int_Visor_t{
    uint32_t random1;
    uint32_t random2;
    int   last_step;
};

#ifdef __cplusplus
}
#endif

#endif // _KB_RGB_INT_TYPE_H_
